<?xml version="1.0" encoding="UTF-8"?>
	<xsl:stylesheet version="1.0" xmlns:marc="http://www.loc.gov/MARC21/slim" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
	<xsl:output encoding="utf-8" method="xml"/>
	<xsl:strip-space elements="*"/>
	
	<xsl:template match="/">
		<xsl:choose>
			<xsl:when test="collection">
				<xsl:apply-templates select="collection"/>
			</xsl:when>
		</xsl:choose>
	</xsl:template>
	
	<xsl:template match="collection">
		<Session>
    <xsl:choose>
      <xsl:when test="marc:record">
				<Formdata>
					<xsl:apply-templates select="marc:record"/>
				</Formdata>
      </xsl:when>
    </xsl:choose>
		</Session>
  </xsl:template>

  <xsl:template match="marc:record">
    <xsl:if test="marc:datafield[@tag='546' and @ind1=' ' and @ind2=' ']/marc:subfield[@code='a']">
		<language><xsl:apply-templates select="marc:datafield[@tag='546' and @ind1=' ' and @ind2=' ']/marc:subfield[@code='a']"/></language>
	</xsl:if>
    <xsl:choose>      
      <xsl:when test="marc:datafield[@tag='655' and @ind2='7']">
          <xsl:variable name="type" select="marc:datafield[@tag='655' and @ind2='7']/marc:subfield[@code='a']"/>
          <xsl:variable name="book">Book</xsl:variable>
          <xsl:variable name="book_chapter">Book Chapter</xsl:variable>
          <xsl:variable name="conference_paper">Conference Paper</xsl:variable>
          <xsl:variable name="conference_item">Conference Item</xsl:variable>
          <xsl:variable name="thesis">Thesis</xsl:variable>
          <xsl:variable name="journal_article">Journal Article</xsl:variable>
          <xsl:variable name="working_paper">Working Paper</xsl:variable>
          <xsl:variable name="reports">Report</xsl:variable>
          <xsl:variable name="other_resource">Other Resource</xsl:variable>
					<resource_type><xsl:value-of select="$type"/></resource_type>
          <xsl:if test="$type = $book">
            <xsl:call-template name="printBook"/>
          </xsl:if>
          <xsl:if test="$type = $book_chapter">
            <xsl:call-template name="printBookChapter"/>
          </xsl:if>          
          <xsl:if test="$type = $conference_paper">
            <xsl:call-template name="printConferencePaper"/>
          </xsl:if>
          <xsl:if test="$type = $conference_item">
            <xsl:call-template name="printConferenceItem"/>
          </xsl:if>
          <xsl:if test="$type = $thesis">
            <xsl:call-template name="printThesis"/>
          </xsl:if>
          <xsl:if test="$type = $journal_article">
            <xsl:call-template name="printJournal"/>
          </xsl:if>
          <xsl:if test="$type = $working_paper">
            <xsl:call-template name="printWorkingPaper"/>
          </xsl:if>
          <xsl:if test="$type = $reports">
            <xsl:call-template name="printReports"/>
          </xsl:if>
      </xsl:when>
    </xsl:choose>
		
		<!-- title -->
    <xsl:if test="marc:datafield[@ind1='1' and @ind2='0' and @tag='245']/marc:subfield[@code='a']">
			<title><xsl:apply-templates select="marc:datafield[@ind1='1' and @ind2='0' and @tag='245']/marc:subfield[@code='a']"/></title>
    </xsl:if>
		
		<!-- Year -->
		<xsl:if test="marc:datafield[@tag='260' and @ind1=' ' and @ind2=' ']/marc:subfield[@code='c']">
      <year><xsl:apply-templates select="marc:datafield[@tag='260' and @ind1=' ' and @ind2=' ']/marc:subfield[@code='c']"/></year>
    </xsl:if>
		
		<!-- abstract -->
		<xsl:if test="marc:datafield[@tag='520' and @ind1='3' and @ind2=' ']/marc:subfield[@code='a']">
			<description_abstract><xsl:apply-templates select="marc:datafield[@tag='520' and @ind1='3' and @ind2=' ']/marc:subfield[@code='a']" /></description_abstract>
		</xsl:if>
		
		<!-- subject or keyword -->
		<xsl:variable name="subject">
			<xsl:apply-templates select="marc:datafield[@tag='653' and @ind1=' ' and @ind2=' ']/marc:subfield[@code='a']">
				<xsl:with-param name="filter">true</xsl:with-param>
			</xsl:apply-templates>
		</xsl:variable>
		
		<xsl:if test="string-length(normalize-space($subject)) &gt; 0">
			<subject><xsl:value-of select="$subject"/></subject>
		</xsl:if>
		
		<xsl:variable name="keyword">
			<xsl:apply-templates select="marc:datafield[@tag='653' and @ind1=' ' and @ind2=' ']/marc:subfield[@code='a']">
				<xsl:with-param name="filter">false</xsl:with-param>
			</xsl:apply-templates>
		</xsl:variable>
		
		<xsl:if test="string-length(normalize-space($keyword)) &gt; 0">
			<keyword><xsl:value-of select="$keyword"/></keyword>
		</xsl:if>

		<xsl:variable name="firstCreator">
			<xsl:apply-templates select="marc:datafield[@tag='100' and @ind1='1' and @ind2=' ']"/>
		</xsl:variable>
		
		<xsl:variable name="otherCreator">
			<xsl:apply-templates select="marc:datafield[@tag='100' and @ind1=' ' and @ind2=' ']"/>
		</xsl:variable>
		
		<xsl:if test="string-length(normalize-space($firstCreator)) &gt; 0">
		<creators><xsl:value-of select="$firstCreator"/>
		<xsl:if test="string-length(normalize-space($otherCreator)) &gt; 0"><xsl:text>&#13;</xsl:text><xsl:value-of select="$otherCreator"/></xsl:if>
		</creators>
		</xsl:if>
		
		<!-- Publisher Statement -->
		<xsl:if test="marc:datafield[@tag='540' and @ind1=' ' and @ind2=' ']/marc:subfield[@code='a']">
			<publisher_statement><xsl:apply-templates select="marc:datafield[@tag='540' and @ind1=' ' and @ind2=' ']/marc:subfield[@code='a']"/></publisher_statement>
		</xsl:if>
		
		<xsl:if test="marc:datafield[@tag='500' and @ind1=' ' and @ind2=' ']/marc:subfield[@code='a']">
			<additional_info><xsl:apply-templates select="marc:datafield[@tag='500' and @ind1=' ' and @ind2=' ']/marc:subfield[@code='a']"/></additional_info>
		</xsl:if>
		
		<xsl:if test="marc:datafield[@tag='710' and @ind1=' ' and @ind2=' ']/marc:subfield[@code='a']">
			<university><xsl:apply-templates select="marc:datafield[@tag='710' and @ind1=' ' and @ind2=' ']/marc:subfield[@code='a']"/></university>
		</xsl:if>
				
		<xsl:if test="marc:datafield[@tag='540' and @ind1=' ' and @ind2='0']/marc:subfield[@code='a']">
			<rights><xsl:apply-templates select="marc:datafield[@tag='540' and @ind1=' ' and @ind2='0']/marc:subfield[@code='a']"/></rights>
		</xsl:if>

  </xsl:template>
	
	<xsl:template match="marc:datafield[@tag='100' and @ind1='1' and @ind2=' ']">
		<xsl:variable name="creator" select="marc:subfield[@code='a']" />
		<xsl:variable name="affiliation" select="marc:subfield[@code='u']" />
		<xsl:variable name="pointer" select="position()" />
    <xsl:variable name="total" select="last()" />
		<xsl:choose>
		<xsl:when test="string-length($affiliation) &gt; 0"><xsl:value-of select="$creator"/> ; <xsl:value-of select="$affiliation"/></xsl:when>
		<xsl:otherwise><xsl:value-of select="$creator"/></xsl:otherwise>
		</xsl:choose>
	</xsl:template>
	
	<xsl:template match="marc:datafield[@tag='100' and @ind1=' ' and @ind2=' ']">
		<xsl:variable name="creator" select="marc:subfield[@code='a']" />
		<xsl:variable name="affiliation" select="marc:subfield[@code='u']" />
		<xsl:variable name="pointer" select="position()" />
    <xsl:variable name="total" select="last()" />
		<xsl:choose>
		<xsl:when test="$pointer  &lt; $total">
		<xsl:value-of select="$creator"/> ; <xsl:value-of select="$affiliation"/>
		<xsl:text>&#13;</xsl:text>
		</xsl:when>
		<xsl:otherwise><xsl:value-of select="$creator"/> ; <xsl:value-of select="$affiliation"/></xsl:otherwise>
		</xsl:choose>
	</xsl:template>
	
	<xsl:template match="marc:datafield[@tag='653' and @ind1=' ' and @ind2=' ']/marc:subfield[@code='a']">
		<xsl:param name="filter"/>
		<xsl:variable name="value" select="."/>
		<xsl:choose>
		<xsl:when test="$filter = 'true'">
			<xsl:choose>
			<xsl:when test="contains($value, '(RFCD:')">
				<xsl:call-template name="getContent">
					<xsl:with-param name="content" select="$value"/>
				</xsl:call-template>
			</xsl:when>
			</xsl:choose>
		</xsl:when>
		<xsl:otherwise>
			<xsl:choose>
			<xsl:when test="not(contains($value, '(RFCD:'))">
				<xsl:call-template name="getContent">
					<xsl:with-param name="content" select="$value"/>
				</xsl:call-template>
			</xsl:when>
			</xsl:choose>
		</xsl:otherwise>
		</xsl:choose>
	</xsl:template>

	<xsl:template name="getContent">
		<xsl:param name="content"/>
		<xsl:variable name="pointer" select="position()" />
    <xsl:variable name="total" select="last()" />
		<xsl:choose>
		<xsl:when test="$pointer  &lt; $total"><xsl:value-of select="$content"/><xsl:text>&#13;</xsl:text></xsl:when>
		<xsl:otherwise><xsl:value-of select="$content"/></xsl:otherwise>
		</xsl:choose>
	</xsl:template>
	
	<xsl:template name="printWorkingPaper">
	
		<xsl:if test="marc:datafield[@tag='020' and @ind1=' ' and @ind2=' ']/marc:subfield[@code='a']">
			<working_paper_isbn><xsl:apply-templates select="marc:datafield[@tag='020' and @ind1=' ' and @ind2=' ']/marc:subfield[@code='a']"/></working_paper_isbn>
		</xsl:if>
	
		<xsl:if test="marc:datafield[@tag='022' and @ind1=' ' and @ind2=' ']/marc:subfield[@code='a']">
			<working_paper_issn><xsl:apply-templates select="marc:datafield[@tag='022' and @ind1=' ' and @ind2=' ']/marc:subfield[@code='a']"/></working_paper_issn>
		</xsl:if>

		<xsl:if test="marc:datafield[@tag='830' and @ind1=' ' and @ind2=' ']/marc:subfield[@code='a']">
			<working_paper_title><xsl:apply-templates select="marc:datafield[@tag='830' and @ind1=' ' and @ind2=' ']/marc:subfield[@code='a']"/></working_paper_title>
		</xsl:if>
		
		<xsl:if test="marc:datafield[@tag='830' and @ind1=' ' and @ind2=' ']/marc:subfield[@code='v']">
			<working_paper_number><xsl:apply-templates select="marc:datafield[@tag='830' and @ind1=' ' and @ind2=' ']/marc:subfield[@code='v']"/></working_paper_number>
		</xsl:if>
		
		<xsl:if test="marc:datafield[@tag='260' and @ind1=' ' and @ind2=' ']/marc:subfield[@code='b']">
			<working_paper_publisher><xsl:apply-templates select="marc:datafield[@tag='260' and @ind1=' ' and @ind2=' ']/marc:subfield[@code='b']"/></working_paper_publisher>
		</xsl:if>
		
		<xsl:if test="marc:datafield[@tag='260' and @ind1=' ' and @ind2=' ']/marc:subfield[@code='a']">
			<working_paper_place_publication><xsl:apply-templates select="marc:datafield[@tag='260' and @ind1=' ' and @ind2=' ']/marc:subfield[@code='a']"/></working_paper_place_publication>
		</xsl:if>

		<xsl:if test="marc:datafield[@tag='787' and @ind1=' ' and @ind2=' ']/marc:subfield[@code='n']">
			<working_paper_peer_reviewed><xsl:apply-templates select="marc:datafield[@tag='787' and @ind1=' ' and @ind2=' ']/marc:subfield[@code='n']" /></working_paper_peer_reviewed>
		</xsl:if>
		
		<xsl:if test="marc:datafield[@tag='856' and @ind1='4' and @ind2='0']/marc:subfield[@code='u']">
			<working_paper_url><xsl:apply-templates select="marc:datafield[@tag='856' and @ind1='4' and @ind2='0']/marc:subfield[@code='u']" /></working_paper_url>
		</xsl:if>
		
	</xsl:template>
	
	<xsl:template name="printJournal">

		<xsl:if test="marc:datafield[@tag='022' and @ind1=' ' and @ind2=' ']/marc:subfield[@code='a']">
			<journal_issn><xsl:apply-templates select="marc:datafield[@tag='022' and @ind1=' ' and @ind2=' ']/marc:subfield[@code='a']"/></journal_issn>
		</xsl:if>

		<xsl:if test="marc:datafield[@tag='024' and @ind1=' ' and @ind2=' ']/marc:subfield[@code='a']">
			<journal_doi><xsl:apply-templates select="marc:datafield[@tag='024' and @ind1=' ' and @ind2=' ']/marc:subfield[@code='a']"/></journal_doi>
		</xsl:if>
		
		<xsl:if test="marc:datafield[@tag='787' and @ind1=' ' and @ind2=' ']/marc:subfield[@code='t']">
			<journal_title><xsl:apply-templates select="marc:datafield[@tag='787' and @ind1=' ' and @ind2=' ']/marc:subfield[@code='t']" /></journal_title>
		</xsl:if>
		
		<xsl:if test="marc:datafield[@tag='787' and @ind1=' ' and @ind2=' ']/marc:subfield[@code='n']">
			<journal_peer_reviewed><xsl:apply-templates select="marc:datafield[@tag='787' and @ind1=' ' and @ind2=' ']/marc:subfield[@code='n']" /></journal_peer_reviewed>
		</xsl:if>
		
		<xsl:if test="marc:datafield[@tag='787' and @ind1=' ' and @ind2=' ']/marc:subfield[@code='g']">
			<xsl:call-template name="getVolumeIssuePage">
				<xsl:with-param name="value" select="marc:datafield[@tag='787' and @ind1=' ' and @ind2=' ']/marc:subfield[@code='g']" />
			</xsl:call-template>
		</xsl:if>
		
		<xsl:if test="marc:datafield[@tag='260' and @ind1=' ' and @ind2=' ']/marc:subfield[@code='b']">
			<journal_publisher><xsl:apply-templates select="marc:datafield[@tag='260' and @ind1=' ' and @ind2=' ']/marc:subfield[@code='b']"/></journal_publisher>
		</xsl:if>
		
		<xsl:if test="marc:datafield[@tag='260' and @ind1=' ' and @ind2=' ']/marc:subfield[@code='a']">
			<journal_place_publication><xsl:apply-templates select="marc:datafield[@tag='260' and @ind1=' ' and @ind2=' ']/marc:subfield[@code='a']"/></journal_place_publication>
		</xsl:if>
		
	</xsl:template>
	
	<xsl:template name="printThesis">
		
		<xsl:variable name="supervisor">
			<xsl:apply-templates select="marc:datafield[@tag='720' and @ind1=' ' and @ind2=' ']/marc:subfield[@code='a']"/>
		</xsl:variable>
		
		<xsl:if test="string-length(normalize-space($supervisor)) &gt; 0">
			<thesis_supervisor><xsl:value-of select="$supervisor"/></thesis_supervisor>
		</xsl:if>
			
		<xsl:if test="marc:datafield[@tag='260' and @ind1=' ' and @ind2=' ']/marc:subfield[@code='a']">
			<thesis_place_publication><xsl:apply-templates select="marc:datafield[@tag='260' and @ind1=' ' and @ind2=' ']/marc:subfield[@code='a']"/></thesis_place_publication>
		</xsl:if>
		
		<xsl:if test="marc:datafield[@tag='260' and @ind1=' ' and @ind2=' ']/marc:subfield[@code='b']">
			<thesis_publisher><xsl:apply-templates select="marc:datafield[@tag='260' and @ind1=' ' and @ind2=' ']/marc:subfield[@code='b']"/></thesis_publisher>
		</xsl:if>
		
		<xsl:if test="marc:datafield[@tag='502' and @ind1='3' and @ind2=' ']/marc:subfield[@code='u']">
			<thesis_degree><xsl:apply-templates select="marc:datafield[@tag='502' and @ind1='3' and @ind2=' ']/marc:subfield[@code='u']"/></thesis_degree>
		</xsl:if>
		
	</xsl:template>
	
	<!-- Supervisor of Thesis -->
	<xsl:template match="marc:datafield[@tag='720' and @ind1=' ' and @ind2=' ']/marc:subfield[@code='a']">
		<xsl:variable name="value" select="." />
		<xsl:variable name="pointer" select="position()" />
		<xsl:variable name="total" select="last()" />
		<xsl:choose>
			<xsl:when test="$pointer &lt; $total"><xsl:value-of select="$value"/><xsl:text>&#13;</xsl:text></xsl:when>
			<xsl:otherwise><xsl:value-of select="$value" /></xsl:otherwise>
		</xsl:choose>
	</xsl:template>
	
	<xsl:template name="printConferencePaper">
	
		<xsl:if test="marc:datafield[@tag='711' and @ind1='0' and @ind2=' ']/marc:subfield[@code='t']">
			<conference_title><xsl:apply-templates select="marc:datafield[@tag='711' and @ind1='0' and @ind2=' ']/marc:subfield[@code='t']"/></conference_title>
		</xsl:if>
		
		<xsl:if test="marc:datafield[@tag='711' and @ind1='0' and @ind2=' ']/marc:subfield[@code='c']">
			<conference_location><xsl:apply-templates select="marc:datafield[@tag='711' and @ind1='0' and @ind2=' ']/marc:subfield[@code='c']"/></conference_location>
		</xsl:if>
		
		<xsl:if test="marc:datafield[@tag='711' and @ind1='0' and @ind2=' ']/marc:subfield[@code='d']">
			<xsl:variable name="year" select="marc:datafield[@tag='260' and @ind1=' ' and @ind2=' ']/marc:subfield[@code='c']"/>
			<xsl:variable name="date" select="marc:datafield[@tag='711' and @ind1='0' and @ind2=' ']/marc:subfield[@code='d']"/>
			<xsl:if test="$year != $date">
				<conference_month><xsl:value-of select="normalize-space(substring-before($date, $year))"/></conference_month>
			</xsl:if>
		</xsl:if>
		
		<xsl:if test="marc:datafield[@tag='787' and @ind1=' ' and @ind2='0']/marc:subfield[@code='a']">
			<conference_name><xsl:apply-templates select="marc:datafield[@tag='787' and @ind1=' ' and @ind2='0']/marc:subfield[@code='a']"/></conference_name>
		</xsl:if>
		
		<xsl:if test="marc:datafield[@tag='787' and @ind1=' ' and @ind2='0']/marc:subfield[@code='n']">
			<conference_peer_reviewed><xsl:apply-templates select="marc:datafield[@tag='787' and @ind1=' ' and @ind2='0']/marc:subfield[@code='n']"/></conference_peer_reviewed>
		</xsl:if>
		
		<xsl:if test="marc:datafield[@tag='787' and @ind1=' ' and @ind2='0']/marc:subfield[@code='g']">
			<xsl:variable name="page" select="marc:datafield[@tag='787' and @ind1=' ' and @ind2='0']/marc:subfield[@code='g']"/>
			<xsl:variable name="ppText">pp.</xsl:variable>
			<xsl:variable name="line" select="'-'"/>
			<conference_page_from><xsl:value-of select="normalize-space(substring-before(substring-after($page, $ppText), $line))"/></conference_page_from>
			<conference_page_to><xsl:value-of select="normalize-space(substring-after(substring-after($page, $ppText), $line))"/></conference_page_to>
		</xsl:if>
			
		<xsl:if test="marc:datafield[@tag='020' and @ind1=' ' and @ind2=' ']/marc:subfield[@code='a']">
			<conference_isbn><xsl:apply-templates select="marc:datafield[@tag='020' and @ind1=' ' and @ind2=' ']/marc:subfield[@code='a']"/></conference_isbn>
		</xsl:if>
		
		<xsl:if test="marc:datafield[@tag='022' and @ind1=' ' and @ind2=' ']/marc:subfield[@code='a']">
			<conference_issn><xsl:apply-templates select="marc:datafield[@tag='022' and @ind1=' ' and @ind2=' ']/marc:subfield[@code='a']"/></conference_issn>
		</xsl:if>
		
		<xsl:if test="marc:datafield[@tag='260' and @ind1=' ' and @ind2=' ']/marc:subfield[@code='a']">
			<conference_place_publication><xsl:apply-templates select="marc:datafield[@tag='260' and @ind1=' ' and @ind2=' ']/marc:subfield[@code='a']"/></conference_place_publication>
		</xsl:if>
		
		<xsl:if test="marc:datafield[@tag='260' and @ind1=' ' and @ind2=' ']/marc:subfield[@code='b']">
			<conference_publisher><xsl:apply-templates select="marc:datafield[@tag='260' and @ind1=' ' and @ind2=' ']/marc:subfield[@code='b']"/></conference_publisher>
		</xsl:if>
		
		<xsl:if test="marc:datafield[@tag='260' and @ind1=' ' and @ind2=' ']/marc:subfield[@code='c']">
			<conference_proceedings_year><xsl:apply-templates select="marc:datafield[@tag='260' and @ind1=' ' and @ind2=' ']/marc:subfield[@code='c']"/></conference_proceedings_year>
		</xsl:if>
		
		<xsl:if test="marc:datafield[@tag='856' and @ind1='4' and @ind2='0']/marc:subfield[@code='u']">
			<conference_url><xsl:apply-templates select="marc:datafield[@tag='856' and @ind1='4' and @ind2='0']/marc:subfield[@code='u']"/></conference_url>
		</xsl:if>
	
	</xsl:template>
	
	<xsl:template name="printConferenceItem">
	
		<xsl:if test="marc:datafield[@tag='711' and @ind1='0' and @ind2=' ']/marc:subfield[@code='t']">
			<conference_item_title><xsl:apply-templates select="marc:datafield[@tag='711' and @ind1='0' and @ind2=' ']/marc:subfield[@code='t']"/></conference_item_title>
		</xsl:if>
		
		<xsl:if test="marc:datafield[@tag='711' and @ind1='0' and @ind2=' ']/marc:subfield[@code='c']">
			<conference_item_location><xsl:apply-templates select="marc:datafield[@tag='711' and @ind1='0' and @ind2=' ']/marc:subfield[@code='c']"/></conference_item_location>
		</xsl:if>
		
		<xsl:if test="marc:datafield[@tag='711' and @ind1='0' and @ind2=' ']/marc:subfield[@code='d']">
			<xsl:variable name="year" select="marc:datafield[@tag='260' and @ind1=' ' and @ind2=' ']/marc:subfield[@code='c']"/>
			<xsl:variable name="date" select="marc:datafield[@tag='711' and @ind1='0' and @ind2=' ']/marc:subfield[@code='d']"/>
			<xsl:if test="$year != $date">
				<conference_item_date><xsl:value-of select="normalize-space(substring-before($date, $year))"/></conference_item_date>
			</xsl:if>
		</xsl:if>
	
		<xsl:if test="marc:datafield[@tag='787' and @ind1=' ' and @ind2='0']/marc:subfield[@code='a']">
			<conference_item_name><xsl:apply-templates select="marc:datafield[@tag='787' and @ind1=' ' and @ind2='0']/marc:subfield[@code='a']"/></conference_item_name>
		</xsl:if>
		
		<xsl:if test="marc:datafield[@tag='787' and @ind1=' ' and @ind2='0']/marc:subfield[@code='n']">
			<conference_item_peer_reviewed><xsl:apply-templates select="marc:datafield[@tag='787' and @ind1=' ' and @ind2='0']/marc:subfield[@code='n']"/></conference_item_peer_reviewed>
		</xsl:if>
		
		<xsl:if test="marc:datafield[@tag='787' and @ind1=' ' and @ind2='0']/marc:subfield[@code='g']">
			<xsl:variable name="page" select="marc:datafield[@tag='787' and @ind1=' ' and @ind2='0']/marc:subfield[@code='g']"/>
			<xsl:variable name="ppText">pp.</xsl:variable>
			<xsl:variable name="line" select="'-'"/>
			<conference_item_page_from><xsl:value-of select="normalize-space(substring-before(substring-after($page, $ppText), $line))"/></conference_item_page_from>
			<conference_item_page_to><xsl:value-of select="normalize-space(substring-after(substring-after($page, $ppText), $line))"/></conference_item_page_to>
		</xsl:if>
		
		<xsl:if test="marc:datafield[@tag='020' and @ind1=' ' and @ind2=' ']/marc:subfield[@code='a']">
			<conference_item_isbn><xsl:apply-templates select="marc:datafield[@tag='020' and @ind1=' ' and @ind2=' ']/marc:subfield[@code='a']"/></conference_item_isbn>
		</xsl:if>
		
		<xsl:if test="marc:datafield[@tag='022' and @ind1=' ' and @ind2=' ']/marc:subfield[@code='a']">
			<conference_item_issn><xsl:apply-templates select="marc:datafield[@tag='022' and @ind1=' ' and @ind2=' ']/marc:subfield[@code='a']"/></conference_item_issn>
		</xsl:if>
		
		<xsl:if test="marc:datafield[@tag='260' and @ind1=' ' and @ind2=' ']/marc:subfield[@code='a']">
			<conference_item_place_publication><xsl:apply-templates select="marc:datafield[@tag='260' and @ind1=' ' and @ind2=' ']/marc:subfield[@code='a']"/></conference_item_place_publication>
		</xsl:if>
		
		<xsl:if test="marc:datafield[@tag='260' and @ind1=' ' and @ind2=' ']/marc:subfield[@code='b']">
			<conference_item_publisher><xsl:apply-templates select="marc:datafield[@tag='260' and @ind1=' ' and @ind2=' ']/marc:subfield[@code='b']"/></conference_item_publisher>
		</xsl:if>
		
		<xsl:if test="marc:datafield[@tag='260' and @ind1=' ' and @ind2=' ']/marc:subfield[@code='c']">
			<conference_item_proceedings_year><xsl:apply-templates select="marc:datafield[@tag='260' and @ind1=' ' and @ind2=' ']/marc:subfield[@code='c']"/></conference_item_proceedings_year>
		</xsl:if>

		<xsl:if test="marc:datafield[@tag='856' and @ind1='4' and @ind2='0']/marc:subfield[@code='u']">
			<conference_item_url><xsl:apply-templates select="marc:datafield[@tag='856' and @ind1='4' and @ind2='0']/marc:subfield[@code='u']"/></conference_item_url>
		</xsl:if>
		
	</xsl:template>
	
	<xsl:template name="printBookChapter">
		
		<xsl:variable name="editor">
			<xsl:apply-templates select="marc:datafield[@tag='700' and @ind1='1' and @ind2=' ']/marc:subfield[@code='a']">
				<xsl:with-param name="editor" select="marc:datafield[@tag='700' and @ind1='1' and @ind2=' ']/marc:subfield[@code='e']"/>
			</xsl:apply-templates>
		</xsl:variable>
		
		<xsl:if test="string-length(normalize-space($editor)) &gt; 0">
			<editor><xsl:value-of select="$editor"/></editor>
		</xsl:if>
		
		<xsl:if test="marc:datafield[@tag='260' and @ind1=' ' and @ind2=' ']/marc:subfield[@code='a']">
			<chapter_place_publication><xsl:apply-templates select="marc:datafield[@tag='260' and @ind1=' ' and @ind2=' ']/marc:subfield[@code='a']"/></chapter_place_publication>
		</xsl:if>
		
		<xsl:if test="marc:datafield[@tag='260' and @ind1=' ' and @ind2=' ']/marc:subfield[@code='b']">
			<chapter_publisher><xsl:apply-templates select="marc:datafield[@tag='260' and @ind1=' ' and @ind2=' ']/marc:subfield[@code='b']"/></chapter_publisher>
		</xsl:if>
		
		<xsl:if test="marc:datafield[@tag='020' and @ind1=' ' and @ind2=' ']/marc:subfield[@code='a']">
			<chapter_isbn><xsl:apply-templates select="marc:datafield[@tag='020' and @ind1=' ' and @ind2=' ']/marc:subfield[@code='a']"/></chapter_isbn>
		</xsl:if>
		
		<xsl:if test="marc:datafield[@tag='787' and @ind1=' ' and @ind2='0']/marc:subfield[@code='t']">
			<chapter_book_title><xsl:apply-templates select="marc:datafield[@tag='787' and @ind1=' ' and @ind2='0']/marc:subfield[@code='t']"/></chapter_book_title>
		</xsl:if>
		
		<xsl:if test="marc:datafield[@tag='787' and @ind1=' ' and @ind2='0']/marc:subfield[@code='g']">
			<xsl:variable name="page" select="marc:datafield[@tag='787' and @ind1=' ' and @ind2='0']/marc:subfield[@code='g']"/>
			<xsl:variable name="ppText">pp.</xsl:variable>
			<xsl:variable name="line" select="'-'"/>
			<chapter_page_from><xsl:value-of select="normalize-space(substring-before(substring-after($page, $ppText), $line))"/></chapter_page_from>
			<chapter_page_to><xsl:value-of select="normalize-space(substring-after(substring-after($page, $ppText), $line))"/></chapter_page_to>
		</xsl:if>
				
		<xsl:if test="marc:datafield[@tag='250' and @ind1=' ' and @ind2=' ']/marc:subfield[@code='a']">
			<chapter_edition><xsl:apply-templates select="marc:datafield[@tag='250' and @ind1=' ' and @ind2=' ']/marc:subfield[@code='a']"/></chapter_edition>
		</xsl:if>
		
		<xsl:if test="marc:datafield[@tag='787' and @ind1=' ' and @ind2='0']/marc:subfield[@code='n']">
			<chapter_peer_reviewed><xsl:apply-templates select="marc:datafield[@tag='787' and @ind1=' ' and @ind2='0']/marc:subfield[@code='n']"/></chapter_peer_reviewed>
		</xsl:if>
		
		<xsl:if test="marc:datafield[@tag='856' and @ind1='4' and @ind2='0']/marc:subfield[@code='u']">
			<chapter_url><xsl:apply-templates select="marc:datafield[@tag='856' and @ind1='4' and @ind2='0']/marc:subfield[@code='u']"/></chapter_url>
		</xsl:if>
		
	</xsl:template>
	
	<xsl:template match="marc:datafield[@tag='700' and @ind1='1' and @ind2=' ']/marc:subfield[@code='a']">
		<xsl:param name="editor" />
		<xsl:variable name="name" select="."/>
		<xsl:variable name="filter" select="Editor"/>
		<xsl:variable name="joint" select="','"/>
		<xsl:variable name="pointer" select="position()" />
		<xsl:variable name="total" select="last()" />
		<xsl:choose>
			<xsl:when test="$editor = $filter">
				<xsl:choose>
					<xsl:when test="$pointer &lt; $total"><xsl:value-of select="normalize-space($name)"/><xsl:text>&#13;</xsl:text></xsl:when>
					<xsl:otherwise><xsl:value-of select="normalize-space($name)"/></xsl:otherwise>
				</xsl:choose>
			</xsl:when>
		</xsl:choose>	
	</xsl:template>
	
	<xsl:template name="printBook">
		
		<xsl:if test="marc:datafield[@tag='260' and @ind1=' ' and @ind2=' ']/marc:subfield[@code='a']">
			<book_place_publication><xsl:apply-templates select="marc:datafield[@tag='260' and @ind1=' ' and @ind2=' ']/marc:subfield[@code='a']"/></book_place_publication>
		</xsl:if>
		
		<xsl:if test="marc:datafield[@tag='260' and @ind1=' ' and @ind2=' ']/marc:subfield[@code='b']">
			<book_publisher><xsl:apply-templates select="marc:datafield[@tag='260' and @ind1=' ' and @ind2=' ']/marc:subfield[@code='b']"/></book_publisher>
		</xsl:if>
		
		<xsl:if test="marc:datafield[@tag='020' and @ind1=' ' and @ind2=' ']/marc:subfield[@code='a']">
			<book_isbn><xsl:apply-templates select="marc:datafield[@tag='020' and @ind1=' ' and @ind2=' ']/marc:subfield[@code='a']"/></book_isbn>
		</xsl:if>
		
		<xsl:if test="marc:datafield[@tag='250' and @ind1=' ' and @ind2=' ']/marc:subfield[@code='a']">
			<book_edition><xsl:apply-templates select="marc:datafield[@tag='250' and @ind1=' ' and @ind2=' ']/marc:subfield[@code='a']"/></book_edition>
		</xsl:if>

		<xsl:if test="marc:datafield[@tag='787' and @ind1=' ' and @ind2='0']/marc:subfield[@code='n']">
			<book_peer_reviewed><xsl:apply-templates select="marc:datafield[@tag='787' and @ind1=' ' and @ind2='0']/marc:subfield[@code='n']"/></book_peer_reviewed>
		</xsl:if>	
		
		<xsl:if test="marc:datafield[@tag='856' and @ind1='4' and @ind2='0']/marc:subfield[@code='u']">
			<book_url><xsl:apply-templates select="marc:datafield[@tag='856' and @ind1='4' and @ind2='0']/marc:subfield[@code='u']"/></book_url>
		</xsl:if>
		
	</xsl:template>
	
	<xsl:template name="printReports">

		<xsl:if test="marc:datafield[@tag='020' and @ind1=' ' and @ind2=' ']/marc:subfield[@code='a']">
			<report_isbn><xsl:apply-templates select="marc:datafield[@tag='020' and @ind1=' ' and @ind2=' ']/marc:subfield[@code='a']"/></report_isbn>
		</xsl:if>

		<xsl:if test="marc:datafield[@tag='830' and @ind1=' ' and @ind2=' ']/marc:subfield[@code='v']">
			<report_series_no><xsl:apply-templates select="marc:datafield[@tag='830' and @ind1=' ' and @ind2=' ']/marc:subfield[@code='v']"/></report_series_no>
		</xsl:if>
				
		<xsl:if test="marc:datafield[@tag='260' and @ind1=' ' and @ind2=' ']/marc:subfield[@code='b']">
			<report_publisher><xsl:apply-templates select="marc:datafield[@tag='260' and @ind1=' ' and @ind2=' ']/marc:subfield[@code='b']"/></report_publisher>
		</xsl:if>
		
		<xsl:if test="marc:datafield[@tag='260' and @ind1=' ' and @ind2=' ']/marc:subfield[@code='a']">
			<report_place_publication><xsl:apply-templates select="marc:datafield[@tag='260' and @ind1=' ' and @ind2=' ']/marc:subfield[@code='a']"/></report_place_publication>
		</xsl:if>
		
		<xsl:if test="marc:datafield[@tag='250' and @ind1=' ' and @ind2=' ']/marc:subfield[@code='a']">
			<report_edition><xsl:apply-templates select="marc:datafield[@tag='250' and @ind1=' ' and @ind2=' ']/marc:subfield[@code='a']"/></report_edition>
		</xsl:if>
		
		<xsl:if test="marc:datafield[@tag='856' and @ind1='4' and @ind2='0']/marc:subfield[@code='u']">
			<report_url><xsl:apply-templates select="marc:datafield[@tag='856' and @ind1='4' and @ind2='0']/marc:subfield[@code='u']"/></report_url>
		</xsl:if>
		
	</xsl:template>

	<xsl:template name="getVolumeIssuePage">
		<xsl:param name="value"/>
		<xsl:variable name="delimiter" select="';'" />
    <xsl:variable name="colon" select="':'" />
    <xsl:variable name="dot" select="'.'" />
    <xsl:variable name="volText">Vol:</xsl:variable>
    <xsl:variable name="issText">Issue:</xsl:variable>
		<xsl:variable name="ppText">pp.</xsl:variable>
		<xsl:variable name="line" select="'-'"/>
    <xsl:if test="contains($value, $volText)" ><journal_volume>
		<xsl:choose>
		<xsl:when test="contains(substring-after($value, $volText), $delimiter)"><xsl:value-of select="substring-before(substring-after($value, $volText), $delimiter)" /></xsl:when>
		<xsl:otherwise><xsl:value-of select="substring-after($value, $volText)" /></xsl:otherwise>
		</xsl:choose></journal_volume>
		</xsl:if>
    <xsl:if test="contains($value, $issText)" ><journal_issue>
		<xsl:choose>
		<xsl:when test="contains(substring-after($value, $issText), $delimiter)"><xsl:value-of select="substring-before(substring-after($value, $issText), $delimiter)" /></xsl:when>
		<xsl:otherwise><xsl:value-of select="substring-after($value, $issText)" /></xsl:otherwise>
		</xsl:choose></journal_issue>
		</xsl:if>
    <xsl:if test="contains($value, $ppText)" >
			<journal_page_from><xsl:value-of select="substring-before(substring-after($value, $ppText), $line)" /></journal_page_from>
			<journal_page_to><xsl:value-of select="substring-after(substring-after($value, $ppText), $line)" /></journal_page_to>
		</xsl:if>
	</xsl:template>

  <xsl:template name="replace">
    <xsl:param name="input"/>
    <xsl:param name="lookfor"/>
    <xsl:param name="replacement"/>
    <xsl:choose>
      <xsl:when test="contains($input, $lookfor)">
        <xsl:value-of select="concat(substring-before($input, $lookfor), $replacement)"/>
        <xsl:call-template name="replace">
          <xsl:with-param name="input" select="substring-after($input, $lookfor)"/>
          <xsl:with-param name="lookfor" select="$lookfor"/>
          <xsl:with-param name="replacement" select="$replacement"/>
        </xsl:call-template>
      </xsl:when>
      <xsl:otherwise>
        <xsl:value-of select="$input"/>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>

</xsl:stylesheet>
	